using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace ICP_MS.Plugin.Advance;

public class FormSerial : Form
{
	private IContainer components = null;

	private Label label1;

	private TextBox txtSerial1;

	private Label label4;

	private TextBox txtSerial2;

	private Label label2;

	private GroupBox groupBox1;

	private GroupBox groupBox2;

	private TextBox txtDetector;

	private Label label5;

	private Label label6;

	private Label label7;

	private Button button1;

	private Button button2;

	private CheckBox chkTurbo2;

	private CheckBox chkTurbo1;

	private CheckBox chkDetector;

	public FormSerial()
	{
		InitializeComponent();
	}

	private void button2_Click(object sender, EventArgs e)
	{
		base.DialogResult = DialogResult.Cancel;
	}

	private void label1_Click(object sender, EventArgs e)
	{
	}

	private void button1_Click(object sender, EventArgs e)
	{
		try
		{
			SerialConfig serialConfig = new SerialConfig();
			string SerialConfigPath = Application.StartupPath + "//iMassConfig//SerialConfig.xml";
			if (!XMLFile.Open(SerialConfigPath, ref serialConfig))
			{
				serialConfig = new SerialConfig();
			}
			if (chkTurbo1.Checked)
			{
				serialConfig.Turbo1 = txtSerial1.Text;
			}
			if (chkTurbo2.Checked)
			{
				serialConfig.Turbo2 = txtSerial2.Text;
			}
			if (chkDetector.Checked)
			{
				serialConfig.Detector = txtDetector.Text;
			}
			XMLFile.Save(SerialConfigPath, serialConfig);
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message, Lang.Txt("AddFormIonSource.Warn"), MessageBoxButtons.OK);
		}
		base.DialogResult = DialogResult.OK;
	}

	private void FormSerial_Load(object sender, EventArgs e)
	{
		ApplyResources();
		try
		{
			SerialConfig serialConfig = new SerialConfig();
			string SerialConfigPath = Application.StartupPath + "//iMassConfig//SerialConfig.xml";
			if (!XMLFile.Open(SerialConfigPath, ref serialConfig))
			{
				serialConfig = new SerialConfig();
			}
			txtSerial1.Text = serialConfig.Turbo1;
			txtSerial2.Text = serialConfig.Turbo2;
			txtDetector.Text = serialConfig.Detector;
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message, Lang.Txt("AddFormIonSource.Warn"), MessageBoxButtons.OK);
		}
	}

	private void ApplyResources()
	{
		Text = Lang.Txt("FormSerial.Text");
		groupBox1.Text = Lang.Txt("FormSerial.MolecularPump");
		label1.Text = Lang.Txt("FormSerial.Text1");
		label6.Text = Lang.Txt("FormSerial.Text2");
		label7.Text = Lang.Txt("FormSerial.Text3");
		groupBox2.Text = Lang.Txt("FormSerial.Multiplier");
		label2.Text = Lang.Txt("FormSerial.Pump1Serial");
		label4.Text = Lang.Txt("FormSerial.Pump2Serial");
		label5.Text = Lang.Txt("FormSerial.MultiplierSerial");
		button1.Text = Lang.Txt("FormSerial.OK");
		button2.Text = Lang.Txt("FormSerial.Cancel");
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.label1 = new System.Windows.Forms.Label();
		this.txtSerial1 = new System.Windows.Forms.TextBox();
		this.label4 = new System.Windows.Forms.Label();
		this.txtSerial2 = new System.Windows.Forms.TextBox();
		this.label2 = new System.Windows.Forms.Label();
		this.groupBox1 = new System.Windows.Forms.GroupBox();
		this.chkTurbo2 = new System.Windows.Forms.CheckBox();
		this.chkTurbo1 = new System.Windows.Forms.CheckBox();
		this.groupBox2 = new System.Windows.Forms.GroupBox();
		this.chkDetector = new System.Windows.Forms.CheckBox();
		this.txtDetector = new System.Windows.Forms.TextBox();
		this.label5 = new System.Windows.Forms.Label();
		this.label6 = new System.Windows.Forms.Label();
		this.label7 = new System.Windows.Forms.Label();
		this.button1 = new System.Windows.Forms.Button();
		this.button2 = new System.Windows.Forms.Button();
		this.groupBox1.SuspendLayout();
		this.groupBox2.SuspendLayout();
		base.SuspendLayout();
		this.label1.AutoSize = true;
		this.label1.ForeColor = System.Drawing.Color.Red;
		this.label1.Location = new System.Drawing.Point(15, 31);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(442, 15);
		this.label1.TabIndex = 0;
		this.label1.Text = "若更换分子泵，请填写新分子泵的序列号，并勾选相应的复选框：";
		this.label1.Click += new System.EventHandler(label1_Click);
		this.txtSerial1.Location = new System.Drawing.Point(173, 100);
		this.txtSerial1.Name = "txtSerial1";
		this.txtSerial1.Size = new System.Drawing.Size(296, 25);
		this.txtSerial1.TabIndex = 17;
		this.label4.AutoSize = true;
		this.label4.Location = new System.Drawing.Point(39, 107);
		this.label4.Name = "label4";
		this.label4.Size = new System.Drawing.Size(128, 15);
		this.label4.TabIndex = 16;
		this.label4.Text = "分子泵2-序列号：";
		this.txtSerial2.Location = new System.Drawing.Point(173, 62);
		this.txtSerial2.Name = "txtSerial2";
		this.txtSerial2.Size = new System.Drawing.Size(296, 25);
		this.txtSerial2.TabIndex = 15;
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(39, 72);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(128, 15);
		this.label2.TabIndex = 14;
		this.label2.Text = "分子泵1-序列号：";
		this.groupBox1.Controls.Add(this.chkTurbo2);
		this.groupBox1.Controls.Add(this.chkTurbo1);
		this.groupBox1.Controls.Add(this.txtSerial1);
		this.groupBox1.Controls.Add(this.label4);
		this.groupBox1.Controls.Add(this.txtSerial2);
		this.groupBox1.Controls.Add(this.label2);
		this.groupBox1.Controls.Add(this.label1);
		this.groupBox1.Location = new System.Drawing.Point(12, 11);
		this.groupBox1.Name = "groupBox1";
		this.groupBox1.Size = new System.Drawing.Size(726, 145);
		this.groupBox1.TabIndex = 18;
		this.groupBox1.TabStop = false;
		this.groupBox1.Text = "分子泵";
		this.chkTurbo2.AutoSize = true;
		this.chkTurbo2.Location = new System.Drawing.Point(486, 107);
		this.chkTurbo2.Name = "chkTurbo2";
		this.chkTurbo2.Size = new System.Drawing.Size(18, 17);
		this.chkTurbo2.TabIndex = 18;
		this.chkTurbo2.UseVisualStyleBackColor = true;
		this.chkTurbo1.AutoSize = true;
		this.chkTurbo1.Location = new System.Drawing.Point(486, 66);
		this.chkTurbo1.Name = "chkTurbo1";
		this.chkTurbo1.Size = new System.Drawing.Size(18, 17);
		this.chkTurbo1.TabIndex = 18;
		this.chkTurbo1.UseVisualStyleBackColor = true;
		this.groupBox2.Controls.Add(this.chkDetector);
		this.groupBox2.Controls.Add(this.txtDetector);
		this.groupBox2.Controls.Add(this.label5);
		this.groupBox2.Controls.Add(this.label6);
		this.groupBox2.Location = new System.Drawing.Point(12, 162);
		this.groupBox2.Name = "groupBox2";
		this.groupBox2.Size = new System.Drawing.Size(726, 119);
		this.groupBox2.TabIndex = 18;
		this.groupBox2.TabStop = false;
		this.groupBox2.Text = "倍增器";
		this.chkDetector.AutoSize = true;
		this.chkDetector.Location = new System.Drawing.Point(486, 65);
		this.chkDetector.Name = "chkDetector";
		this.chkDetector.Size = new System.Drawing.Size(18, 17);
		this.chkDetector.TabIndex = 18;
		this.chkDetector.UseVisualStyleBackColor = true;
		this.txtDetector.Location = new System.Drawing.Point(173, 62);
		this.txtDetector.Name = "txtDetector";
		this.txtDetector.Size = new System.Drawing.Size(296, 25);
		this.txtDetector.TabIndex = 15;
		this.label5.AutoSize = true;
		this.label5.Location = new System.Drawing.Point(47, 69);
		this.label5.Name = "label5";
		this.label5.Size = new System.Drawing.Size(120, 15);
		this.label5.TabIndex = 14;
		this.label5.Text = "倍增器-序列号：";
		this.label6.AutoSize = true;
		this.label6.ForeColor = System.Drawing.Color.Red;
		this.label6.Location = new System.Drawing.Point(15, 31);
		this.label6.Name = "label6";
		this.label6.Size = new System.Drawing.Size(442, 15);
		this.label6.TabIndex = 0;
		this.label6.Text = "若更换倍增器，请填写新倍增器的序列号，并勾选相应的复选框：";
		this.label7.AutoSize = true;
		this.label7.ForeColor = System.Drawing.Color.DodgerBlue;
		this.label7.Location = new System.Drawing.Point(27, 310);
		this.label7.Name = "label7";
		this.label7.Size = new System.Drawing.Size(187, 15);
		this.label7.TabIndex = 0;
		this.label7.Text = "若未更换，请直接点击取消";
		this.button1.Location = new System.Drawing.Point(476, 372);
		this.button1.Name = "button1";
		this.button1.Size = new System.Drawing.Size(102, 31);
		this.button1.TabIndex = 19;
		this.button1.Text = "确定";
		this.button1.UseVisualStyleBackColor = true;
		this.button1.Click += new System.EventHandler(button1_Click);
		this.button2.Location = new System.Drawing.Point(606, 372);
		this.button2.Name = "button2";
		this.button2.Size = new System.Drawing.Size(102, 31);
		this.button2.TabIndex = 19;
		this.button2.Text = "取消";
		this.button2.UseVisualStyleBackColor = true;
		this.button2.Click += new System.EventHandler(button2_Click);
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 15f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(800, 450);
		base.Controls.Add(this.button2);
		base.Controls.Add(this.button1);
		base.Controls.Add(this.groupBox2);
		base.Controls.Add(this.groupBox1);
		base.Controls.Add(this.label7);
		base.Name = "FormSerial";
		this.Text = "更换倍增器和分子泵";
		base.Load += new System.EventHandler(FormSerial_Load);
		this.groupBox1.ResumeLayout(false);
		this.groupBox1.PerformLayout();
		this.groupBox2.ResumeLayout(false);
		this.groupBox2.PerformLayout();
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
